package com.xul.yygh.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xul.yygh.common.result.Result;
import com.xul.yygh.order.service.OrderInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import model.com.xul.yygh.enums.OrderStatusEnum;
import model.com.xul.yygh.model.order.OrderInfo;
import model.com.xul.yygh.vo.order.OrderQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xul
 * @create 2021-07-22 10:42
 */

@Api(tags = "平台订单接口")
@RestController
@RequestMapping("admin/order/orderInfo")
public class OrderController {

    @Autowired
    private OrderInfoService orderInfoService;

    /**
     * 获取分页列表
     *
     * @param page
     * @param limit
     * @param orderQueryVo
     * @return
     */
    @ApiOperation("获取分页列表")
    @GetMapping("{page}/{limit}")
    public Result index(@PathVariable Long page,
                        @PathVariable Long limit,
                        OrderQueryVo orderQueryVo) {
        Page<OrderInfo> pageParam = new Page<>(page, limit);
        IPage<OrderInfo> pageModel = orderInfoService.selectPage(pageParam, orderQueryVo);
        return Result.ok(pageModel);
    }

    /**
     * 获取订单状态
     *
     * @return
     */
    @ApiOperation("获取订单状态")
    @GetMapping("getStatusList")
    public Result getStatusList() {
        return Result.ok(OrderStatusEnum.getStatusList());
    }

    /**
     * 获取订单详情
     * @param id
     * @return
     */
    @ApiOperation("获取订单")
    @GetMapping("show/{id}")
    public Result get(@PathVariable Long id) {
        return Result.ok(orderInfoService.show(id));
    }

}
